package com.cmnit.analysis.service

import com.cmnit.analysis.dao.NoTransWithPicDao
import com.cmnit.analysis.util.{ConfigurationManager, ServiceUtil}
import org.apache.log4j.Logger

class NoTransWithPicService {
  private val logger: Logger = Logger.getLogger(this.getClass)
  private val dao = new NoTransWithPicDao

  def service(acctTime: String): Unit = {
    // 获取加工账期（默认当前时间的前两天）
    val sqlTime = ServiceUtil.getAcctInfo(acctTime)
    logger.info("加工账期时间：" + acctTime)

    // 删除需要插入的账期数据
    dao.delete(ConfigurationManager.getProperty("NoTransWithPic.TableName"), ConfigurationManager.getProperty("NoTransWithPic.time"), acctTime)

    // 写入数据
    dao.write(ConfigurationManager.getProperty("NoTransWithPic.TableName"), dao.NoTransWithPicData(sqlTime, acctTime))

    // 查看写入结果
    dao.read(ConfigurationManager.getProperty("NoTransWithPic.TableName"), ConfigurationManager.getProperty("NoTransWithPic.time"), acctTime)
  }
}